<template>
  <es-table ref="tcTable" :data="tableData" :tableColumnList="tableColumnList" @selection-change="handleSelectionChange"
    :height="tableHeight + 'px'">
    <template #createTime="scope">
      {{ dayjs(scope.row.updateTime).format('YYYY.MM.DD') }}
    </template>
    <template #caozuo="scope">
      <el-button class="tablebtn" key="primary" type="primary" size="small" text
        @click.stop="handleStockAllIn(scope.row)">查看</el-button>
      <el-button class="tablebtn" key="primary" type="primary" size="small" text
        @click.stop="handleUpdate(scope.row)">编辑</el-button>
    </template>
  </es-table>
</template>

<script setup lang="ts">
import {
  ref,
  computed,
  onMounted,
} from 'vue'
import { getTableColumnList } from "./tableColumns.ts";
import { ElMessage, dayjs } from "element-plus";
import { gettableList } from '@/api/table/index.ts'

let tableColumnList = computed(() => {
  return getTableColumnList('tableone');
})


let selectionDataList = ref([])  //勾选行
let tableHeight = ref()
const handleSelectionChange = (value: any) => {
  selectionDataList.value = value; // 记录勾选列表行
  console.log(value, '勾选');

}

let tableData = ref([]) // 表格数据
onMounted(async () => {
  try {
    const res = await gettableList()
    if (res.code == 200) {
      tableData.value = res.data
      console.log(res, 'mock2');

      ElMessage({
        type: "success",
        message: res.message,
      })
    }
  } catch (error) {
    ElMessage({
      type: "error",
      message: '获取失败',
    })
  }
  tableHeight.value = document.body.clientHeight; // 获取表格高度，网页可见区域的高度减去其他元素高度
})

// 查看
const handleStockAllIn = (val) => {

}
// 编辑
const handleUpdate = (val) => {

}


</script>